package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.StrategyTheme;
import cn.wolfcode.wolf2w.qurey.StrategyThemeQuery;
import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.IStrategyThemeService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("strategyTheme")
public class StrategyThemeController {

    @Autowired
    private IStrategyThemeService strategyThemeService;
    @Autowired
    private IDestinationService destinationService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")StrategyThemeQuery qo){
        //PageInfo  : 分页数据封装对象, Mybatis插件, 操作的是Mysql数据库
        //Page : 分页数据封装对象, spring-data 的组件, 操作是mongodb
        Page<StrategyTheme> page = strategyThemeService.query(qo);
        model.addAttribute("page", page);

        return "strategyTheme/list";
    }

   


    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyTheme strategyTheme){

        strategyThemeService.saveOrUpdate(strategyTheme);

        return JsonResult.success();
    }

    @GetMapping("/delete")
    @ResponseBody
    private Object delete(String id){
        strategyThemeService.delete(id);
        return JsonResult.success();
    }



}
